
$(function(){
    //登录
    login();
});


function login(){
    $("#loginBtn").click(function(){
        var username = $("#username").val();
        var password = $("#password").val();
        $.ajax({
            url: context +"login",
            type: "post",
            dataType: "json",
            data:{'username':username,"password":password},
            traditional: true,
            success: function(result){
                debugger
                if(result.code == "0"){
                    window.location.href = context + "index";
                }else{
                    alert("登录失败!")
                }
            },error:function(){
                alert("服务器异常!");
            }
        });
    });
}
